<?php
class Default_Model_DbTable_Comment extends Zend_Db_Table_Abstract {
	protected $_name = 'comment';
	public function addComment($user_id, $content, $dateup, $status) {
		$data = array (
				'USER_ID' => $user_id,
				'CONTENT' => $content,
				'DATEUP' => $dateup,
				'STATUS' => $status 
		);
		return $this->insert ( $data );
	}
	public function updateComment($comment_id, $user_id, $content, $dateup, $status) {
		$data = array (
				'USER_ID' => $user_id,
				'CONTENT' => $content,
				'DATEUP' => $dateup,
				'STATUS' => $status 
		);
		return $this->update ( $data, "ID= $comment_id" );
	}
	public function updateStatus($comment_id, $status) {
		$data = array (
				'STATUS' => $status 
		);
		return $this->update ( $data, "ID= $comment_id" );
	}
	public function removeStatus($comment_id) {
		return $this->delete ( "ID = $comment_id" );
	}
	public function getAllComment() {
		return $this->fetchAll ( "STATUS = 1 " )->toArray ();
	}
	public function getCommentByUserId($user_id, $status) {
		return $this->fetchAll("USER_ID = $user_id and STATUS = $status");
	}
	public function getCommentByUserName($user_name, $status) {
		$tuser = new Default_Model_DbTable_User();
		$user = $tuser->GetByName($user_name);
		$id = $user["ID"];
		return $this->fetchAll("USER_ID = $id And STATUS = $status");
	}
	public function getCommentById($comment_id, $status) {
		return $this->fetchRow("ID = $comment_id And STATUS = $status");
	}
	public function getCommentByStatus($status) {
		return $this->fetchAll("STATUS = $status");
	}
	//get comment by new
	public function GetCommentByNew($NewID){
		return $this->fetchAll("NEWS_ID = $NewID");
	}
}

